package cn.edu.scau.cmi.chenzehan.client;

import java.util.HashSet;
import java.util.Set;



import cn.edu.scau.cmi.chenzehan.multipPattern.OutstandingYouth;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

public class MultipMode extends Application {

	private Parent root;
	private Button button1;
	private TextArea ta; 
	private Set<OutstandingYouth> teamYouth = new HashSet<OutstandingYouth>();    
	@Override
	public void start(Stage primaryStage) throws Exception {
		
		
		 OutstandingYouth.addYouths("张三");
		 OutstandingYouth.addYouths("李四");
		 OutstandingYouth.addYouths("王五");
		 OutstandingYouth.addYouths("赵六");
		 OutstandingYouth.addYouths("陈七");
		 OutstandingYouth.addYouths("刘德华");
		 OutstandingYouth.addYouths("周润发");
		 OutstandingYouth.addYouths("张学友");
		 OutstandingYouth.addYouths("周杰伦");
		 OutstandingYouth.addYouths("邓紫棋");
		 OutstandingYouth.addYouths("胡歌");
		 teamYouth = OutstandingYouth.addYouths("彭于晏");
		 
		 root = FXMLLoader.load(getClass().getResource("MultiMode.fxml"));
		 button1 = (Button) root.lookup("#button1");
		 ta = (TextArea) root.lookup("#ta");
		 
		 button1.setOnAction(e->{
			 ta.appendText("十大杰出青年有："+"\n");
			 teamYouth = OutstandingYouth.addYouths("彭于晏");
			 for(OutstandingYouth i : teamYouth) {
				// System.out.print( i.getName()+",");
				 ta.appendText(i.getName()+",");
			 }
			 ta.appendText("\n");
		 });
		 
		 Scene scene = new Scene(root);
		 primaryStage.setTitle("实验一：多例模式");
			primaryStage.setScene(scene);
			primaryStage.show();
	}
	public static void main(String[] args) {
		 
		launch(args);
//		 for(OutstandingYouth i : teamYouth) {
//			 System.out.print( i.getName()+",");
//
//		 }	
	}


	

}
